package com.hqyj.crmdemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hqyj.crmdemo.entity.Custmer;
import com.hqyj.crmdemo.entity.Report;
import com.hqyj.crmdemo.entity.SaleChance;
import com.hqyj.crmdemo.mapper.CustmerMapper;
import com.hqyj.crmdemo.service.ICustmerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 何万林
 * @since 2022-10-17
 */
@Service
public class CustmerServiceImpl extends ServiceImpl<CustmerMapper, Custmer> implements ICustmerService {

    @Autowired
    CustmerMapper mapper;

    public List<Report> countByLevel(){
        List<Report> reports=mapper.countByLevel();
        return reports;
    }

    @Override
    public Custmer queryOne(Integer custmerId) {
        Custmer custmer = mapper.selectById(custmerId);
        return custmer;
    }

    @Override
    public List<Custmer> queryAll() {
        List<Custmer> custmers = mapper.selectList(null);
        return custmers;
    }

    @Override
    public List<Custmer> queryOne(QueryWrapper queryWrapper) {
        List<Custmer> custmers = mapper.selectList(queryWrapper);
        return custmers;
    }

    @Override
    public Boolean add(Custmer custmer) {
        int insert = mapper.insert(custmer);
        return insert > 0 ? true : false;
    }

    @Override
    public Boolean update(Custmer custmer) {
        int update = mapper.updateById(custmer);
        return update > 0 ? true : false;
    }

    @Override
    public Boolean delete(Integer custmerId) {
        int delete = mapper.deleteById(custmerId);
        return delete > 0 ? true : false;
    }
}
